<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>调查问卷Drag</title>
    <script src="../js/jquery.min.js"></script>
</head>
<body>
<style>
    .page {
        width: 1000px;
        margin: 0px auto;
    }

    .left {
        width: 500px;
        float: left;
    }

    .left .container {
        padding: 10px;
        min-height: 500px;
        -webkit-box-sizing: border-box;
        -moz-box-sizing: border-box;
        box-sizing: border-box;
    }

    .left .containerDrop {
        background-color: #eeeeee;

    }

    .left .container h1 {
        text-align: center;
    }

    .right {
        width: 500px;
        float: left;
        box-sizing: border-box;
        border-left: 1px solid red;
    }
    .right .ctrlList{
        padding: 10px;
    }
    .right .ctrlList .box{
        border: 1px dashed gray;
        margin-top: 10px;
        margin-bottom: 10px;
    }
    .line{
        margin-top:10px;
        margin-bottom:10px;
        padding:5px;
    }
</style>
<div class="page">
    <div class="left">
        <div id="container" class="container">
            <h1>问卷</h1>
        </div>
    </div>
    <div class="right">
        <div class="ctrlList">
            <div class="box" draggable="true">
                <div class="line">
                    <span>姓名：</span>
                    <input type="text" name="name" placeholder="请输入输入姓名"/>
                </div>
            </div>
            <div class="box" draggable="true">
                <div class="line">
                    <span>年龄：</span>
                    <input type="text" name="age" placeholder="请输入输入年龄"/>
                </div>
            </div>
            <div class="box" draggable="true">
                <div class="line">
                    <span>性别：</span>
                    <label>
                        <input type="radio" name="gender" value="male"/>
                        男
                    </label>
                    <label>
                        <input type="radio" name="gender" value="female"/>
                        女
                    </label>
                </div>
            </div>
            <div class="box" draggable="true">
                <div class="line">
                    <span>兴趣爱好：</span>
                    <label>
                        <input type="checkbox" name="hobby" value="basketball"/>
                        篮球
                    </label>
                    <label>
                        <input type="checkbox" name="hobby" value="football"/>
                        足球
                    </label>
                    <label>
                        <input type="checkbox" name="hobby" value="tennis"/>
                        网球
                    </label>
                    <label>
                        <input type="checkbox" name="hobby" value="badminton"/>
                        羽毛球
                    </label>
                    <label>
                        <input type="checkbox" name="hobby" value="tabletennis"/>
                        乒乓球
                    </label>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    (function($){
        $('.box').each(function(index,ele){
            $(ele).on("dragstart",function(event){
                dragSrc=this;
            });
        });
        $("#container").on("drop",function(e){
            e.preventDefault();
            $(this).append($(dragSrc).find('.line').clone());
            $(this).removeClass("containerDrop");
        }).on("dragover",function(e){
            e.preventDefault();
        }).on("dragenter",function(e){
            e.preventDefault();
            $(this).addClass("containerDrop");
        }).on("dragleave",function(e){
            e.preventDefault();
            $(this).removeClass("containerDrop");
        });
    })(jQuery);
</script>
</body>
</html>